package base

//null-checks
fun main(args: Array<String>) {
    val x = parseInt(args[0])
    val y = parseInt(args[1])

    // We cannot say 'x * y' now because they may hold nulls
    if (x != null && y != null) {
        print(x * y) // Now we can
    } else {
        println("One of the arguments is null")
    }


    val nullableList: List<Int?> = listOf(1, 2, null, 4)
    val intList: List<Int> = nullableList.filterNotNull()

}

fun parseInt(str: String): Int? {
    try {
        return str.toInt()
    } catch (e: NumberFormatException) {
        println("One of the arguments isn't Int")
    }
    return null
}

